package com.ag.zhh.service;

import com.ag.bean.TbCurrentEvent;
import com.ag.dao.TbCurrentEventDAO;

public class CurrentEventService {
	
	public void processByCurrentEvent(String eventId){
		TbCurrentEvent tbCurrentEvent = tbCurrentEventDAO.findById(eventId);
		if(tbCurrentEvent == null) {
			tbCurrentEvent = new TbCurrentEvent();
			tbCurrentEvent.setEId(eventId);
			tbCurrentEventDAO.save(tbCurrentEvent);
			//更改事件状态：事件处置中
			eventStatusService.changeTbEventStatus(EventStatusService.EVENT_STATUS_SJCHZH_ING, eventId);
		}
	}
	
	public void endProcessByCurrentEvent(String eventId) {
		TbCurrentEvent tbCurrentEvent = tbCurrentEventDAO.findById(eventId);
		if(tbCurrentEvent != null) {
			tbCurrentEventDAO.delete(tbCurrentEvent);
			//更改事件状态：事件处置结束
			eventStatusService.changeTbEventStatus(EventStatusService.EVENT_STATUS_SJCHZH_FINISH, eventId);
		}
	}
	
	public boolean checkEventStatusFinish(String eventId){
		boolean result = false;
		result =eventStatusService.checkEventStatus(EventStatusService.EVENT_STATUS_SJCHZH_FINISH, eventId);
		return result;
	}
	
	private EventStatusService eventStatusService;
	
	private TbCurrentEventDAO tbCurrentEventDAO;

	public TbCurrentEventDAO getTbCurrentEventDAO() {
		return tbCurrentEventDAO;
	}

	public void setTbCurrentEventDAO(TbCurrentEventDAO tbCurrentEventDAO) {
		this.tbCurrentEventDAO = tbCurrentEventDAO;
	}

	public CurrentEventService() {
		super();
	}

	public EventStatusService getEventStatusService() {
		return eventStatusService;
	}

	public void setEventStatusService(EventStatusService eventStatusService) {
		this.eventStatusService = eventStatusService;
	}
	
}
